Use case: VREFBUF configuration

This use case shows how VREFBUF configuration is handled after the HAL GENERIC driver split.

Sequence diagram

Configure and enable VREFBUF via SYSCFG helpers

   @startuml
   participant "User Application" as UA
   participant "HAL Driver" as HAL1

   UA -> HAL1 : HAL_Init()
   HAL1 --> UA : Initialization Complete

   UA -> HAL1 : HAL_SYSCFG_VREFBUF_VoltageScalingConfig()
   HAL1 --> UA : Voltage scaling configured

   UA -> HAL1 : HAL_SYSCFG_VREFBUF_HighImpedanceConfig()
   HAL1 --> UA : High impedance mode configured

   UA -> HAL1 : HAL_SYSCFG_EnableVREFBUF()
   HAL1 --> UA : VREFBUF enabled
   @enduml

Code snippet

HAL1

HAL2

int main(void)
{
    HAL_Init();
    /*
    ...
    */

    /* Set Voltage Scaling */
    HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE0);

    /* Configure the high impedance mode */
    HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE);

    /* Enable VREFBUF */
    HAL_SYSCFG_EnableVREFBUF();
}
int main(void)
{
    HAL_Init();
    /*
    ...
    */
    hal_vrefbuf_config_t p_config;

    p_config.mode = HAL_VREFBUF_MODE_EXT_VOLTAGE_REF;
    p_config.voltage_scale = HAL_VREFBUF_VOLTAGE_SCALE0;

    /* Configure and enable VREFBUF (Voltage scale and VREFBUF mode) */
    HAL_VREFBUF_SetConfig(VREFBUF1, &p_config);

}

Key changes

  1. The HAL GENERIC driver split introduces a dedicated VREFBUF driver for configuration.

  2. In HAL2, VREFBUF configuration and enable are consolidated into HAL_VREFBUF_SetConfig().